package com.zline.foodraise.view;

import android.content.Context;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.zline.foodraise.R;
import com.zline.foodraise.entity.TemplateBean;
import com.zline.foodraise.listener.RecyclerItemClicked;
import com.zline.foodraise.util.ImageUtil;

import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by heshantao on 15/8/30.
 */
@EViewGroup(R.layout.template_choose_item)
public class TemplateChooseItem extends RelativeLayout {
    private static final String LOG_TAG=TemplateChooseItem.class.getSimpleName();
    @ViewById(R.id.template_choose_item_iv)
    ImageView iv;
    RecyclerItemClicked itemClicked;
    int position;
    DisplayImageOptions options;
    ImageLoader imageLoader;
    @Bean
    ImageUtil imageUtil;
    public TemplateChooseItem(Context context) {
        super(context);
    }

    public void bind(TemplateBean bean, int position,DisplayImageOptions options) {
        this.position=position;
       if(bean!=null){
           String thumbpath= bean.getThumbnails();
           imageLoader = ImageLoader.getInstance();
           imageLoader.displayImage(thumbpath, iv, options);
       }
    }

    @Click(R.id.template_choose_item_iv)
    void onClick(){
        itemClicked.onRecyclerItemClicked(position);
    }

    public void setRecycleItemClickListener(RecyclerItemClicked itemClickListener){
        this.itemClicked=itemClickListener;
    }
}
